#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "seqlist.h"

typedef struct Teacher{
    int age;
    char name[64];
}Teacher;

int main()
{
    int ret = 0;
    SeqList *list = NULL;

    Teacher t1,t2,t3,t4,t5;
    t1.age=31;
    t2.age=32;
    t3.age=33;
    t4.age=34;
    t5.age=35;

    list = SeqList_New(10);
    if (list == NULL) {
        printf("fun SeqList_Create()err \n");
        return -1;
    }

    ret = SeqList_Insert(list,(SeqListNode*)&t1,0);//头插法
    ret = SeqList_Insert(list,(SeqListNode*)&t2,0);
    ret = SeqList_Insert(list,(SeqListNode*)&t3,0);
    ret = SeqList_Insert(list,(SeqListNode*)&t4,0);
    ret = SeqList_Insert(list,(SeqListNode*)&t5,0);

    for (int i = 0; i < SeqList_Length(list); ++i) {
        Teacher* tmp = (Teacher*) SeqList_Get(list,i);
        if (tmp == NULL)
            return -1;
        printf("tmp->age=%d\n", tmp->age);
    }

    while (SeqList_Length(list)>0)
    {
        Teacher* tmp = (Teacher*) SeqList_Erase(list,0);//头部删除
        printf("Delete:tmp->age=%d\n", tmp->age);
    }

    return 0;
}
